<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<!--common::heads这里按需添加代码,如果没有link，style，script，则使用~{}填充参数位。参考下面代码-->
<head th:replace="common::heads(~{::title},~{},~{},~{})">
    <meta charset="UTF-8">
    <title>部门信息</title>
</head>
<body>
    <!--整体-->
    <div class="parent">
        <div th:replace="common :: top"></div>
        <div class="middle">
            <div th:replace="common::left"></div>

            <div class="right"  style="display: flex;flex-direction: column;justify-content: center;align-content: center;align-items: center;">
                <h3 style="text-align: center">部门管理</h3>
                <form action="/dept/addOrUpdate" method="post" onsubmit="return save();" style="text-align: center">
                    <input name="id" th:value="${dept==null ? '' : dept.id}" type="hidden">
                    <label>部门名称：</label><input id="name" name="name" th:value="${dept==null ? '' : dept.name}"  type="text">
                    <br>
                    <button style="margin: 20px;width: 100px;" type="submit">保存</button>
                </form>
            </div>
        </div>
        <div th:replace="common::footer"></div>
    </div>

<script>
    function save() {
        var name=document.getElementById('name');
        if(name.value.trim().length===0){
            alert('请输入部门名称');
            return false;
        }

        return true;
    }
</script>
</body>
</html>